Array Methods

Helpful methods for working with arrays

For Each

Array.prototype.forEach()

The forEach() method executes a provided function once for each array element.

Filter

Array.prototype.filter()

The filter() method creates a new array with all elements that pass the test implemented by the provided function.

Map

Array.prototype.map()

The map() method creates a new array with the results of calling a provided function on every element in the calling array.

Reduce

Array.prototype.reduce()

The reduce() method applies a function against an accumulator and each element in the array (from left to right) to reduce it to a single value.

Sort

Array.prototype.sort()

Some

Array.prototype.some() The some() method tests whether at least one element in the array passes the test implemented by the provided function.

Every

Array.prototype.every()

The every() method tests whether all elements in the array pass the test implemented by the provided function.

Find

Array.prototype.find()

The find() method returns the value of the first element in the array that satisfies the provided testing function.

Find Index

Array.prototype.findIndex()